package com.zengdw.account.controller;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zengdw.account.entity.AccountTbl;
import com.zengdw.account.service.AccountTblService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zengdw
 * @createTime 2019/12/24 10:40
 */
@RestController
public class IndexController {
    @Resource
    private AccountTblService accountTblService;

    @PostMapping("/update")
    public void update(@RequestParam Integer id, @RequestParam Integer money){
        LambdaUpdateWrapper<AccountTbl> wrapper = Wrappers.<AccountTbl>lambdaUpdate().setSql("money = money - " + money).eq(AccountTbl::getId, id);
        accountTblService.update(wrapper);
    }
}
